//
//  JHSSicknessTypeChooseController.m
//  病例管理
//
//  Created by chenWei on 2017/3/24.
//  Copyright © 2017年 陈伟. All rights reserved.
//

#import "JHSSicknessTypeChooseController.h"


@interface JHSSicknessTypeChooseController ()

@property (nonatomic, strong) NSArray *dicArr;


@end

@implementation JHSSicknessTypeChooseController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _dicArr = [self loadData];
    
    [self.tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    
    
}

#pragma mark - 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 5;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell" forIndexPath:indexPath];
    
    cell.textLabel.text = _dicArr[indexPath.row][@"name"];
    
    return cell;
    
}


#pragma mark - 加载数据
- (NSArray *)loadData
{
    NSURL *url = [[NSBundle mainBundle]URLForResource:@"illType.plist" withExtension:nil];
    
    NSArray *dicArr = [NSArray arrayWithContentsOfURL:url];
    
    return dicArr.copy;
}


#pragma mark - 代理方法
//选中某一行pop
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //取到选中行对应的数据，返回给上一个控制器
    
    NSLog(@"&&&&&&&&&   %@",_dicArr[indexPath.row]);
    
    NSDictionary *dic = _dicArr[indexPath.row];
    
    if ([self.delegate respondsToSelector:@selector(sicknessTypeChooseController:withNSDictionary:)]) {
        
        [self.delegate sicknessTypeChooseController:self withNSDictionary:dic];
        
    }
    
    [self.navigationController popViewControllerAnimated:YES];
    
    
    
}










@end
